var Protobuf = require('./protobuf.min')
function ProtoCode() {

	var code = {
		'_login_S_role$decode': function (r, l) {

			if (!(r instanceof Protobuf.Reader)) {
				r = Protobuf.Reader.create(r)
			}
			var c = l === undefined ? r.len : r.pos + l, m = {}
			while (r.pos < c) {
				var t = r.uint32()
				var pos = t >>> 3;
				console.log('role+++', pos, r.pos,c);
				switch (pos) {
					case 1:
						m["uid"] = r.int32()
						console.log('role~~~', m, r.pos);
						break
					case 2:
						m["userId"] = r.int32()
						console.log('role~~~', m, r.pos);
						break
					case 3:
						m['name'] = r.string()
						console.log('role~~~', m, r.pos);
						break;
					case 4:
						m["pic"] = r.int32()
						console.log('role~~~', m, r.pos);
						break
					default:
						r.skipType(t & 7)
						break
				}
			}
			console.log('_login_S_role$decode===', m);
			return m
		}
		, '_login_S_login$decode': function (r, l) {
			console.log('this', code);
			if (!(r instanceof Protobuf.Reader)) {
				r = Protobuf.Reader.create(r)
			}
			var c = l === undefined ? r.len : r.pos + l, m = {}
			console.log('_login_S_login$decode', r, l, m);
			while (r.pos < c) {
				var t = r.uint32()
				switch (t >>> 3) {
					case 1:
						m["code"] = r.int32()
						break
					case 2:
						m["token"] = r.string()
						break
					case 3:
						console.log('_login_S_role start====');
						if (!(m["roles"] && m["roles"].length)) { m["roles"] = [] }
						console.log(code._login_S_role$decode);
						var role = code._login_S_role$decode(r,r.int32());
						m["roles"].push(role)
						break
					default:
						r.skipType(t & 7)
						break
				}
			}
			console.log('_login_S_role$decode===', m);
			return m
		}
		, '_login_C_login$encode': function (m, w) {
			if (!w) {
				w = Protobuf.Writer.create()
			}
			if (m["username"] !== undefined && m["username"] !== "")
				w.uint32(10).string(m["username"])
			if (m["password"] !== undefined && m["password"] !== "")
				w.uint32(18).string(m["password"])
			if (m["type"] !== undefined && m["type"] !== "")
				w.uint32(26).string(m["type"])
			return w
		}
	}

	return code;
}

module.exports =  new ProtoCode()

